package com.luojie.controller.user;


import com.luojie.dto.BallDTO;
import com.luojie.result.Result;
import com.luojie.service.BallService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/roger/user/ball")
@Api(tags = "c端用户相关接口")
@Slf4j
public class BallController {

    @Autowired
    private BallService ballService;

    @PostMapping
    @ApiOperation("新增比赛项目")
    public Result addMatch(@RequestBody BallDTO ballDTO) {
        try {
            if (ObjectUtils.isEmpty(ballDTO)) {
                return Result.error("参数错误");
            }
            log.info("新增比赛项目:{}", ballDTO);
            ballService.addball(ballDTO);
            return Result.success("新增比赛项成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.success("新增比赛项失败");
    }
    @PostMapping("/Update")
    @ApiOperation("修改比赛项目")
    public Result updateMatch(@RequestBody BallDTO ballDTO) {
        try {
            if (ObjectUtils.isEmpty(ballDTO)) {
                return Result.error("参数错误");
            }
            log.info("修改比赛项目:{}", ballDTO);
            ballService.updateBall(ballDTO);
            return Result.success("修改比赛项成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.success("修改比赛项失败");
    }


}
